feat(openai): Make include_prompts override data collection when set - #6981
Conversation
Change the default of OpenAIIntegration's include_prompts from True to None (unset). When unset, prompt collection follows the global data_collection.gen_ai.inputs setting; when explicitly set, it takes precedence over the global setting in both directions. The unset default is resolved lazily at call time rather than in __init__, so integrations constructed before sentry_sdk.init() still see the active client's options. Pre-data-collection behavior (defaults to True, subject to send_default_pii) is preserved. Refs PY-2588
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a033d03. Configure here.
| # to send_default_pii). Resolve the unset default here, at call time, | ||
| # rather than in __init__ so that integrations constructed before | ||
| # sentry_sdk.init() still see the active client's options. | ||
| integration.include_prompts = True |
There was a problem hiding this comment.
Unset prompts skip response capture
Medium Severity
When data collection is enabled, _resolve_include_prompts leaves include_prompts as None. Input paths handle that, but response-body gates still use truthiness checks like should_send_default_pii() and integration.include_prompts, so None suppresses gen_ai.response.text even when send_default_pii is on. The default path therefore silently drops AI outputs.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit a033d03. Configure here.
Codecov Results 📊✅ 97278 passed | ⏭️ 6487 skipped | Total: 103765 | Pass Rate: 93.75% | Execution Time: 345m 37s 📊 Comparison with Base Branch
➖ Removed Tests (1)View removed tests
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 2511 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 89.88% 89.90% +0.02%
==========================================
Files 193 193 —
Lines 24832 24853 +21
Branches 8912 8932 +20
==========================================
+ Hits 22319 22342 +23
- Misses 2513 2511 -2
- Partials 1416 1414 -2Generated by Codecov Action |


Change the default of OpenAIIntegration's include_prompts from True to None (unset). When unset, prompt collection follows the global data_collection.gen_ai.inputs setting; when explicitly set, it takes precedence over the global setting in both directions.
The unset default is resolved lazily at call time rather than in init, so integrations constructed before sentry_sdk.init() still see the active client's options. Pre-data-collection behavior (defaults to True, subject to send_default_pii) is preserved.
Refs PY-2588